<template>
	<div>
		
		  <el-autocomplete
		      class="inline-input"
		      v-model="state1"
			  size="smail"
		      :fetch-suggestions="querySearch"
		      placeholder="请输入内容"
		      @select="handleSelect"
		    ></el-autocomplete>
		<button  class="btn" @click="index()">Add</button>
		<p>输入的内容为: {{ state1 }}</p>
		
		<!-- <button  class="btn" @click="testtext()">Add</button> -->
		
		
	</div>
</template>

<script>
	import Aside from '../../components/Aside.vue'
	
	export default{
		data(){
			return{
				message:'',
				
				
				restaurants: [],
				state1: '',
				
				setaddres:'',
				
				setall:'',
				
				
				setvalue:[
					{index:991},
					{index:992},
					{index:993},
					{index:994},
					{index:995}
				],
				shuz:[
						//    {"value":"TextRenderActor5","address":"8"},
						//     {"value":"TextRenderActor6","address":"9"},
						// 	 {"value":"TextRenderActor7","address":"10"},
						// 	  {"value":"TextRenderActor8","address":"11"},
						// 	   {"value":"TextRenderActor9","address":"12"},
						// 	    {"value":"TextRenderActor10","address":"13"}
			       
			        ],
					test:this.$store.state.objectPathname,
					 chinese:[
											
					   {"value":"AtmosphericFog-大气雾"},
						{"value":"Floor-地板"},
						{"value":"LightSource-光源"},
						{"value":"PlayerStart-播放器启动"},
						{"value":"SkySphere-天球"},
						{"value":"SkyLight-天窗"},
						{"value":"SphereReflectionCapture-球形反射捕捉"},
						{"value":"Wall-墙"},
						{"value":"LightmassImportanceVolume-卷"},
						{"value":"SkySphereBlueprint-天球蓝印"},
						{"value":"SphereReflectionCapture-球面反射捕捉"},
						{"value":"NetworkPlayerStart-网络播放器启动"},
						{"value":"DocumentationActor1-文件参与者"}	,
						{"value":"Linear_Stair-直线楼梯"},
						{"value":"Bump-碰撞"},
						{"value":"LeftArm-左臂"},
						{"value":"RightArm-右臂"},
						{"value":"Ramp-斜坡"},
						{"value":"CubeMesh-立方目"},
						{"value":"PostProcessVolume-后期处理体积"},
						{"value":"TextRenderActor-文本渲染器"},
						{"value":"DirectionalLight-平行光"},
						{"value":"ThirdPersonCharacter-第三人称"},
						{"value":"SkyAtmosphere-天空大气"},
						{"value":"VolumetricCloud-体积云"},
						{"value":"ExponentialHeightFog-指数级高度雾"},
						{"value":"BoxReflectionCapture-盒体反射捕获"},
						{"value":"DecalActor-贴花"},
						{"value":"DirectionalLight-定向光源"},
						{"value":"PointLight-点光源"},
						{"value":"SpotLight-聚光灯"},
						{"value":"RectLight-矩形光源"},
						{"value":"BP_Sky_Sphere-BP天球"},
						
					]
			} 
		},
		comments:{
			
			
		},
		mounted(){
			this.getObjectpathname();
			this.getActor();
			this.restaurants = this.loadAll();
		},
		methods:{
			
			close(item){
				// let cc="in"+item;
				
				// this.$refs.incc.style.display="none";
				let indexaddress=item-100
				
				this.setvalue[indexaddress].index=item
				
			},
			index(){
				// this.$refs.input1.style.display="none";
				// let fen =JSON.stringify(this.setall)
				// var jsonArr=[];
				// for(var i=0;i<jsonArr.length;i++){
				// 	jsonArr[i]= fen[i]
				// }
				// console.log(this.setall)
				// let Array,Matchname,RootArray,indexOftarget,Asidename;
				// for(let i=0;i<this.chinese.length;i++){
				// 	 Array =this.chinese[i].value
				// 	 Matchname =Array.match("33333")
				// 	if(Matchname != null){
				// 	 RootArray=Matchname.input
				// 	 indexOftarget=RootArray.indexOf('-')
				// 	 Asidename=RootArray.slice(indexOftarget+1,120)
				// 	}
				// }
				// console.log(Asidename)
				
				if(this.setall == this.setaddres){
				this.$store.commit('saveCurrDbSource',this.setall)
				}
			},
			
			 querySearch(queryString, cb) {
			        var restaurants = this.restaurants;
			        var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
			        // 调用 callback 返回建议列表的数据
			        cb(results);
			      },
			      createFilter(queryString) {
			        return (restaurant) => {
			          return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
			        };
			      },
			      loadAll() {
			        return this.shuz
			      },
			      handleSelect(item) {
					  // let value=item.address
					  // this.setvalue[value].index=value
					
					  this.setaddres=item
					  this.setall=item
	      
			      },
				  getObjectpathname(){
				  	let Text=this.$store.state.objectPath.ReturnValue;
					// let  value2=this.$store.state.value2
					// let Text2=this.$store.state.objectPath.ReturnValue[1];
					
					
					let Textone=Text[0]
					let IndexOfString=Textone.indexOf('PersistentLevel')
					// let IndexOfString2=cctv.indexOf(':')
					// let Projectsource =this.$store.state.properties;
					// let test2=Text[0].length
				  	let slicename=''
				  	let objectPathname =[]
					let inputtex2,IndexOfString2,index,inputtex,IndexOfString1,i2;
				  	for(let i in Text){
							 inputtex=Text[i]
							 IndexOfString1=inputtex.indexOf(':')
							inputtex=inputtex.slice(0,IndexOfString1)
							 i2=Number(i)+1
							
							if(i2 < Text.length){
								 inputtex2=Text[i2]
								 IndexOfString2=inputtex2.indexOf(':')
								 inputtex2=inputtex2.slice(0,IndexOfString2)
							}
							if(inputtex != inputtex2 && inputtex2 !=undefined ){
								index=i
							}
							if(index == undefined || index == i ){
								slicename=Text[i].slice(IndexOfString+16,120)
								objectPathname.push(slicename)
							}else if(i > index){
								slicename=Text[i].slice(IndexOfString2+17,120)
								objectPathname.push(slicename)
								
							}
				  	}
					
				  		console.log(objectPathname)
				  	this.$store.commit('setObjectPathname',objectPathname)
				  	
				  },
				  getActor(){
					 
						  let Array,Matchname,RootArray,indexOftarget,Asidename,accurate,indexwei,accurate2,indexwei2,why,like,accurate3,Matchname1,especially,Matchname2,indexmas,indexwall	;
						  // for(let j=0;j<this.chinese.length;j++){
						  // 	 Array =this.chinese[j].value
						  // 	 Matchname =Array.match("SphereReflectionCapture_1")
						  // 	if(Matchname != null){
						  // 	 RootArray=Matchname.input
						  // 	 indexOftarget=RootArray.indexOf('-')
						  // 	 Asidename=RootArray.slice(indexOftarget+1,120)
						  // 	}
						  // }
						  // console.log(Asidename)
					  
					  
					  
					  
					  for(let i=0;i<this.$store.state.objectPathname.length;i++){	
						  accurate=this.$store.state.objectPathname[i]//获取每个actor的名称
						  especially=accurate.match('Wall')
							 indexwei=accurate.lastIndexOf('_')//定位下标
							 // console.log(accurate)
							 if(indexwei != -1){//判断尾部是否有尾数
								 accurate=accurate.slice(0,indexwei)//删除尾部，精确查询
							 }else{
								 accurate=accurate
							 }
							  // console.log(especially)
						  for(let j=0;j<this.chinese.length;j++){
						  	 Array =this.chinese[j].value
							 if(j<this.$store.state.objectPathname.length){
								  accurate2=this.$store.state.objectPathname[j]
							 indexwei2=accurate2.lastIndexOf('_')//定位下标
							 if(indexwei2 != -1){//判断尾部是否有尾数
								 accurate2=accurate2.slice(0,indexwei2)//删除尾部，精确查询
							 }
							 }
							 
							  
							 Matchname =Array.match(accurate)//查找对应文本
							  like =accurate.match(accurate2)
							 if(accurate.length >accurate2.length && like != null){
								  why=accurate.slice(accurate.length-1)
								 
							 }else{
								 why=''
							 }
							 
							 
							// console.log(like)
							 
						  	if(Matchname != null){
						  	 RootArray=Matchname.input
						  	 indexOftarget=RootArray.indexOf('-')//定位下标
						  	 Asidename=RootArray.slice(indexOftarget+1,120)	//截取中文
						  	}else if(accurate.length >accurate2.length && like != null){
							 accurate3=accurate.slice(0,accurate.length-1)
							 for(let c=0 ;c<this.chinese.length;c++){
								 Array =this.chinese[c].value
								 Matchname1 =Array.match(accurate3)
								 if(Matchname1 != null){
								 	RootArray=Matchname1.input
								 	indexOftarget=RootArray.indexOf('-')//定位下标
								 	Asidename=RootArray.slice(indexOftarget+1,120)+why	//截取中文
								 	
								 }
								 
							 }
							 
	
							}else if(especially != null){
								
								if(accurate.length <=5){
									for(let c=0 ;c<this.chinese.length;c++){
										Array =this.chinese[c].value
										indexwall=accurate.slice(0,accurate.length-1)
										Matchname2 =Array.match(indexwall)
										indexmas =accurate.slice(accurate.length-1)
										if(Matchname2 != null){
											RootArray=Matchname2.input
											indexOftarget=RootArray.indexOf('-')//定位下标
											Asidename=RootArray.slice(indexOftarget+1,120)+indexmas
										}
									}
									
								}else{
									for(let c=0 ;c<this.chinese.length;c++){
										Array =this.chinese[c].value
										indexwall=accurate.slice(0,accurate.length-2)
										Matchname2 =Array.match(indexwall)
										indexmas =accurate.slice(accurate.length-2)
										if(Matchname2 != null){
											RootArray=Matchname2.input
											indexOftarget=RootArray.indexOf('-')//定位下标
											Asidename=RootArray.slice(indexOftarget+1,120)+indexmas
										}
									}
									// console.log(Asidename)
								}
								// console.log(accurate)
							}
						}
						// console.log(accurate)
					  	this.shuz.push({
					  		value:this.$store.state.objectPathname[i],
							// value:accurate,
					  		address:i,
							wenben:Asidename,
							router:accurate
					  	})
					  }
					  
				  }
		}
	}
</script>

<style>
	.inline-input{margin-top: 10px;width: 60%;margin-right: 10px;}.
	.el-icon-close{
		position: relative;
		top: 0px;
		right: 0px;
	}
	.btn{
		width: 15%;
		height: 43px;
		border-radius: 5px;
	}
</style>
